package cn.ecut.dzy;

import org.junit.Test;

/**
 * @program: JavaSEDemo
 * @description: 自增
 * @author: DingZhenYun
 * @create: 2021-08-23 22:50
 **/

public class Test1 {

    @Test
    public void test1(){
        int i = 1;
        int j = i++;//j=1,i=2
        int k = i++ * ++j + ++i * j++;

        System.out.println("i = " + i);//
        System.out.println("j = " + j);//
        System.out.println("k = " + k);//
    }

    @Test
    public void test2(){
        int i = 1;
        int j = i++;
        int k = i++ * ++j + --i * j--;

        System.out.println("i = " + i);
        System.out.println("j = " + j);
        System.out.println("k = " + k);
    }
    @Test
    public void test3(){
        int i = 1;
        int j = ++i + i++ * ++i + i++;

        System.out.println("i = " + i);
        System.out.println("j = " + j);
    }

    @Test
    public void test4(){
        int i = 0;
        int result = ++i/--i;
        System.out.println("result="+result);
    }

    @Test
    public void test5(){
        StringUtil util = new StringUtil();
        String str = "尚硅谷";
        util.change(str);
        System.out.println(str);
    }
    class StringUtil{
        public void change(String str){
            str += "你好";//String对象不可变，一旦修改就会产生新对象
        }
    }
}
